home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4067 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: news.genie.net!usenet
  2. From: i.einman@genie.com (IAN J. EINMAN)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: C vs. C++ -> SAS/C binary size
  5. Date: 17 Feb 1996 22:40:04 GMT
  6. Organization: via GEnie Services (1-800-638-9636 or info@genie.com)
  7. Sender: i.einman@genie.com (IAN J. EINMAN)
  8. Message-ID: <4g5lg4$6jv@rock101.genie.net>
  9. NNTP-Posting-Host: rock102.is.ge.com
  10.  
  11. >>Why such a big difference in size of executables?
  12.  
  13. The comparison you gave was basically the worst case.  The printf function is
  14. very small compared to the iostream class.  But it is unfair to say that
  15. "C++ is much larger than C" because the printf function is useable in C++.
  16.  
  17. In general, classes can be larger than the old C functions, but they are far
  18. more powerful.  When you used the "cout" function, and dumped text to the screen,
  19. you also included all i/o functions: formatting, input/output, file input/output,
  20. and all sorts of stuff, that all comes in one package called the "iostream class".
  21. If you started to call more C functions in the first one, like scanf, fscanf, fprintf,
  22. and a bunch of string functions that you would need to have some of the same formatting
  23. poer the iostream has, the C program would grow much larger, but the C++ program would
  24. have most of this stuff there already.
  25.  
  26. The program you wrote is a useless program.  If it was much larger, with many uses of
  27. the power of C++ where it could make some tasks easier, it would be a fair comparison.
  28. And last of all, there is nothing in the world that stops you from using "printf"
  29. in C++ if it is all that you need to use in your program.
  30.  
  31. You really need to test a major program designed under C and under C++ to make the
  32. comparison, the size of including "printf" vs. the complexity of the iostream class
  33. is not a fair comparision.  The iostream can do things printf could never dream of in
  34. that 6000 byte program it can compile to.
  35.  
  36.